package com.example.lifecycle;

import android.content.Intent;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.view.View;

import com.example.lifecycle.base.BaseActivity;
import com.example.lifecycle.base.FragmentAdapter;
import com.example.lifecycle.di.ActivityInject;
import com.example.lifecycle.main.DaggerMainActivityComponent;
import com.example.lifecycle.main.MainContract;
import com.example.lifecycle.main.MainModule;
import com.example.lifecycle.main.MainPresenter;
import com.example.lifecycle.main.MainRepository;
import com.example.lifecycle.main.MainRepository_Factory;
import com.example.lifecycle.main.MineFragment;

import java.util.ArrayList;
import java.util.List;

import javax.inject.Inject;


public class MainActivity extends BaseActivity implements View.OnClickListener, ActivityInject, MainContract.View {

    List<Fragment> fragments;
    List<View> views;

    @Inject
    HomeFragment homeFragment;

    @Inject
    MineFragment mineFragment;

    @Inject
    MainPresenter mainPresenter;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        DaggerMainActivityComponent.builder().appComponent(getAppComponent()).mainModule(new MainModule(this)).build().inject(this);

        fragments = new ArrayList<>();
        fragments.add(homeFragment);
        fragments.add(mineFragment);

        views = new ArrayList<>();
        views.add(findViewById(R.id.btnHome));
        views.add(findViewById(R.id.btnMine));
        findViewById(R.id.btnStartActivity).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(MainActivity.this, TestActivity.class));
            }
        });

        new FragmentAdapter(this, fragments, views, 0, R.id.flContent);

        mainPresenter.load();

    }

    @Override
    public void onClick(View view) {

    }


    @Override
    public void setPresenter(MainContract.Presenter presenter) {

    }
}
